/*
 * -------------------------------------- 
 * FileName: stack.h 
 * Content:
 *      sequential stack
 * Auther:  杨则瑞 
 * Encode:  utf-8 | CRLF                  
 * -------------------------------------- 
 */
#ifndef _stack
#define _stack

#include<malloc.h>
#include<debuging.h>
#include<memory.h>




#define ns(title) stack_##title

typedef enum ns(error_t)
{
    ns(OK),
    ns(INSUFFICIENT_MEMORORY),
    ns(STACK_EMPTY)

} ns(error_t);


typedef struct ns(t)
{
    void * data;

    size_t _elemSize;
    size_t _len;
    size_t _capacity;
    
    ns(error_t) *_error_handler;

} ns(t);


void ns(init)  (ns(t) * self, size_t elemSize, ns(error_t) * error_handler);
void ns(uninit) ( ns(t) * self);


void *ns(top) (ns(t) * self);
void *ns(push_get) (ns(t) * self);
void ns(pop) (ns(t) * self);

void ns(reserve) (ns(t) * self, size_t new_len);


#undef ns 
#endif